package com.android.gilastv.manager;

import android.content.Context;

import com.android.baselibrary.interface_.OkHttpCallBack;
import com.android.gilastv.constants.ApiConstants;
import com.lzy.okgo.model.HttpMethod;

import java.util.HashMap;
import java.util.Map;

public class API_Manager {

    //登录
    public static void login(Context context, String phone, String code, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.login;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        urlParames.put("smscode", code);
        urlParames.put("phone", phone);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //登录
    public static void loginByPwd(Context context, String username, String password, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.loginByPwd;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        urlParames.put("username", username);
        urlParames.put("password", password);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //我的收藏
    public static void queryUserCollect(Context context, int page, int size, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.queryUserCollect;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        urlParames.put("page", page);
        urlParames.put("size", size);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.GET, url, urlParames, null, bodyParames, callBack);
    }

    //我的喜欢
    public static void queryUserLike(Context context, int page, int size, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.queryUserLike;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        urlParames.put("page", page);
        urlParames.put("size", size);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.GET, url, urlParames, null, bodyParames, callBack);
    }

    //用户收藏
    public static void userCollect(Context context, String type, String videoId, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.userCollect;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        urlParames.put("type", type + "");
        urlParames.put("videoId", videoId);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //用户点赞
    public static void userLike(Context context, String type, String videoId, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.userLike;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        urlParames.put("type", type + "");
        urlParames.put("videoId", videoId);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }


    //发验证码
    public static void sendcode(Context context, String phone, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.sendcode;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        urlParames.put("phone", phone);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //我的-用户信息
    public static void getUserInfo(Context context, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.getUserInfo;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //获取开机图片
    public static void appCover(Context context, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.appCover;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }



    //获取视频分类
    public static void videoTypesList(Context context, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.videoTypesList;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //获取视频列表
    public static void recommendList(Context context,int page, int size,  OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.recommendList;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        urlParames.put("page", page);
        urlParames.put("size", size);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //视频详情
    public static void getVideoInfo(Context context, String id, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.getVideoInfo ;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        urlParames.put("id", id);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.GET, url, urlParames, null, bodyParames, callBack);
    }

    //搜索视频
    public static void queryVideos(Context context, int page, int size, String params, String type, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.queryVideos;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        urlParames.put("params", params);
        urlParames.put("page", page);
        urlParames.put("size", size);
        urlParames.put("type", type);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }

    //相关推荐视频
    public static void getVideoRecommend(Context context, String videoId, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.getVideoRecommend;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        urlParames.put("videoId", videoId);
        bodyParames.put("videoId", videoId);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }





    //反馈
    public static void feedback(Context context, String content,String phone, OkHttpCallBack<?> callBack) {
        String url = Config.SERVER_HOST + ApiConstants.feedback;
        Map<String, Object> urlParames = new HashMap<>();
        Map<String, Object> bodyParames = new HashMap<>();
        bodyParames.put("content", content);
        bodyParames.put("phone", phone);
        OkHttpManager.okHttpRequest_Json(context, HttpMethod.POST, url, urlParames, null, bodyParames, callBack);
    }


}
